<template>
  <div class="home">
    <HomeHeader></HomeHeader>
    <HomeSwiper :swiperList="swiperList"/>
    <Homeicons :icons="icons"/>
    <Homelocation/>
    <Homehot :imglist="imglist"/>
    <Homelike :likelist="likelist"/>
    <Homeweek/>
    <Homefooter/>
  </div>
</template>

<script>
    // 引入Home子组件
    import HomeHeader from './pages/Header'
    import HomeSwiper from './pages/Swiper'
    import Homeicons from './pages/icons'
    import Homelocation from './pages/location'
    import Homehot from './pages/hot'
    import Homelike from './pages/like'
    import Homeweek from './pages/week'
    import Homefooter from './pages/footer'
    import { mapState } from 'vuex';
    export default {
      data(){
        return{
          swiperList:[],
          icons:[],
          imglist:[],
          likelist:[],
        }
      },
      computed:{
        ...mapState(["city"])
      },
      mounted(){
        this.$http.get('/api/data/homedata.json').then(res=>{
          const data = res.data.data;
          console.log(data)
          data.forEach((item,index)=>{
            if(item.city===this.city){
              this.swiperList=item.swiperList;
              this.icons=item.icons;
              this.imglist=item.imglist;
              this.likelist=item.likelist;
            }
          })
          
          // console.log(data);
        })
      },
      // activated(){
      //   console.log()
      // },
        name: "Home",
        components:{
          HomeHeader,
          HomeSwiper,
          Homeicons,
          Homelocation,
          Homehot,
          Homelike,
          Homeweek,
          Homefooter
        }
    }
</script>

<style scoped>

</style>
